package com.platform.user.center.portal.util;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by churcy on 2017/3/6.
 */
public class BaseResponse {

    /**
     * 统一处理返回结果
     * @param data
     * @param code
     * @param msg
     * @return
     */
    public static Map<String, Object> setResponse(Object data, String code, String msg) {
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> message = new HashMap<>();

        result.put("data", data);
        message.put("code", code);
        message.put("message", msg);
        result.put("msg", message);

        return result;
    }

    public static Map<String, Object> setResponse(Object data,ResultCodeAndMessage resultCodeAndMessage) {
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> message = new HashMap<>();

        result.put("data", data);
        message.put("code", resultCodeAndMessage.getCode());
        message.put("message", resultCodeAndMessage.getMessage());
        result.put("msg", message);

        return result;
    }
}
